collectgarbage("stop")
print("init memory:" .. collectgarbage("count"))

function test(...)
    --return 1 + select(1, ...) --A result memory:19.2822265625
    --select(1, ...); return 1  --B result memory:19.2822265625
    --return 1, ...             --C result memory:19.1357421875
    --return 1 + arg[1]	        --D result memory:722.2783203125
    --return 1	                --E result memory:722.2646484375
    --return 1 + 1 		        --F result memory:722.3701171875
    --return 1, unpack(arg)	    --G result memory:722.4169921875
    --return 1, arg[1], ...     --H attempt to index local 'arg' (a nil value)
    --return 1 + #{...}         --I result memory:448.8427734375
    select(1, ...); return {...}  --J result memory:448.9853515625
end

print("start memory:" .. collectgarbage("count"))
for i = 1, 10000
do
    test(i)
end
print("result memory:" .. collectgarbage("count"))
